Home

Computer science

'

\ufeffPart I: Defining Program Syntax Exercises (20 \ufeffPoints)
Give a BNF grammar for each of the languages below. For example, a correct answer for the set of all strings consisting of zero or more concatenated copies of the string ab \ufeffwould be this grammar:
\ufeff::= \ufeffab | \ufeff
There are often many correct answers.
(2 \ufeffpoints) \ufeffThe set of all strings consisting of one or more instances of the letter a.
(3 \ufeffpoints) \ufeffShow that your grammar can derive the following sentences:
a
aa
aaa
(2 \ufeffpoints) \ufeffThe set of all strings consisting of one or more instances of the letter a with a semicolon after each one.
(3 \ufeffpoints) \ufeffShow that your grammar can derive the following sentences:
a;
a; a;
a; a; a;
(2 \ufeffpoints) \ufeffThe set of all strings consisting of an uppercase letter followed by zero or more additional characters, each of which is either an uppercase letter or one of the digits 0 \ufeffthrough 9.
(3 \ufeffpoints) \ufeffShow that your grammar can derive the following sentences:
A
AA
A1
AA1
A1A
(2 \ufeffpoints) \ufeffThe set of all strings consisting of an open bracket (the symbol [ ) \ufefffollowed by a list of one or more digits separated by commas, followed by a closing bracket (the symbol ] ). \ufeffNote that the digits are 0 \ufeffthrough 9.
(3 \ufeffpoints) \ufeffShow that your grammar can derive the following sentences:
[0]
[0,1]
[0,1,2]
'

Answer